package online.longzipeng.mywebdemo.config;

import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

/**
 * @Author: lzp
 * @description: 通过配置类实现EnvironmentAware接口，达到静态变量注入的目的 注意：该方式可能会有未知隐患，只用于学习讨论，不建议用于生产环境
 * @Date: 2023/3/15
 */
@Configuration
public class MyConfig4 implements EnvironmentAware {

	public static String appKey;

	public static String appSecret;

	@Override
	public void setEnvironment(Environment environment) {
		appKey = environment.getProperty("myConfig.appSecret", String.class);
		appSecret = environment.getProperty("myConfig.appKey", String.class);
	}
}
